package iterator;

/**
 * @author zhangxi
 * @date 2021/9/29
 */
public class IteratorPatternDemo {

    public static void main(String[] args) {
        Student student1 = new Student("小王");
        Student student2 = new Student("小张");
        Student student3 = new Student("小利");
        ClassRoom classRoom = new ClassRoom(3);
        classRoom.addStudent(student1);
        classRoom.addStudent(student2);
        classRoom.addStudent(student3);
        Interator interator = classRoom.interator();
        while (interator.hasNext()){
            Student student = (Student) interator.next();
            System.out.println(student);
        }
    }

}

